package com.zkw.gro.cloure.demo

/**
 * Created by Administrator on 2016/4/9 0009.
 */
class MethodClosureMain {
    int limit

    MethodClosureMain(int limit){
        this.limit = limit
    }

    boolean validate (String value){
        return value.length() <= limit
    }



    public static void main(String[] args) {
        MethodClosureMain first = new MethodClosureMain(6)
        MethodClosureMain second = new MethodClosureMain(5)
        Closure firstClosure = first.&validate
        def words = ['long string','medium','short','tiny']
        assert 'medium' == words.find(firstClosure)
        assert 'short' == words.find(second.&validate)

    }

}
